﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LanzhouBeefNoodles.Models;
using LanzhouBeefNoodles.ViewsModels;
using Microsoft.AspNetCore.Mvc;

namespace LanzhouBeefNoodles.controllers
{
    public class HomeController : Controller
    {
        private readonly INoodle _noodle;
        private readonly IFeedback _feedback;

        public HomeController(INoodle noodle,IFeedback feedback)
        {
            _noodle = noodle;
            _feedback = feedback;
        }

        public IActionResult Index()
        {
            var viewModle = new HomeViewModel()
            {
                Feedbacks = _feedback.GetAllFeedbacks().ToList(),
                Noodles = _noodle.GetAllNoodles().ToList()
            };
            return View(viewModle);
        }

        public IActionResult Detail(int id)
        {
            return View(_noodle.GetNoodleById(id));
        }
    }
}
